package com.letao.rest.controller;

import com.letao.common.pojo.LetaoResult;
import com.letao.rest.service.ContentService;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by ac on 2017/1/18.
 */
@Controller
@RequestMapping("/content")
public class ContentController {
    @Autowired
    private ContentService contentService;

    @RequestMapping("/list/{categoryId}")
    @ResponseBody
    public LetaoResult queryList(@PathVariable Long categoryId){
        try {
            return contentService.getContentList(categoryId);
        }catch (Exception e){
            e.printStackTrace();
            return LetaoResult.build(500, ExceptionUtils.getStackTrace(e));
        }
    }
}
